/**
 * @file   MiraPoint2DHom.h
 * @author Josep Sabater (jsabaterm@el.ub.edu)
 * @date   September, 2015
 * @version 1.0.0
 * @ingroup MiraGeometryLib
 * @brief 2D Point for Homogeneous operations.
 *
 *
 */

#ifndef MIRA_POINT_2D_HOM_H
#define MIRA_POINT_2D_HOM_H

#include <ostream>
#include "MiraOrientation.h"


namespace MiraGeometryLib{
   /**
    * @class Point2D Homogeneous
    * @brief Implementation of Point 2D for Homogeneous transformations
    */
   class Vector2D; // forward declaration

   class Point2DHom {
    public:
       /**
        * @brief Constructor for Point2DHom.
        * @details This is the default constructor.
        * @return A Point2DHom object where its components (x, y) are both 0.
        */
       Point2DHom(): x_(0), y_(0), h_(1){};
       /**
        * @brief Constructor for Point2DHom
        * @details Constructor that specifies the values of the vector.
        * @ param x Component X.
        * @ param y Component Y.
        * @return A Point2DHom object where its components (x, y) are the ones
        * given by the caller.
        */
       Point2DHom(const double x, const double y) : x_(x), y_(y), h_(1){};
       Point2DHom(const double x,
                  const double y,
                  const double h) : x_(x), y_(y), h_(h){};
                  
       Point2DHom(const Vector2D &vec);                  

       double x() const { return x_; };
       void x(const double x) { x_ = x; };
       double y() const { return y_; }
       void y(const double y) { y_ = y; };
       double h() const { return h_; }
       void h(const double y) { h_ = y; };

       Point2DHom& operator = (Point2DHom ph);
       bool operator == (const Point2DHom& ph) const;
       bool operator != (const Point2DHom& ph) const;

       friend std::ostream& operator << (std::ostream& os, const Point2DHom& ph);

   private:
       double x_; //! < Component X of the 2D point Homogeneous.
       double y_; //! < Component Y of the 2D point Homogeneous.
       double h_; //! < Component Homogeneous of the 2D point Hom.

       static const int zeroRoundDigits_;
       /**
        * @brief Swaps of the date of given 2D vector with the data of this Vector2D.
        * @details This member function should never fail.
        * @param vect Vector2D to copy data from.
        * @return Nothing
        * @see        Assignemt Operator in C++
        * @see        https://en.wikipedia.org/wiki/Assignment_operator_(C%2B%2B)
        */
       void swap(Point2DHom& vect);
    };
}

#endif
